package com.cyx.exercise.ollama;

import java.util.ArrayList;
import java.util.List;

/**
 * Ollama聊天请求对象
 */
public class OllamaChatRequest {
    private String model;
    private List<OllamaChatMessage> messages;
    private boolean stream;
    
    public OllamaChatRequest() {
        this.messages = new ArrayList<>();
    }
    
    public OllamaChatRequest(String model) {
        this.model = model;
        this.messages = new ArrayList<>();
        this.stream = false;
    }
    
    public OllamaChatRequest(String model, List<OllamaChatMessage> messages) {
        this.model = model;
        this.messages = messages != null ? messages : new ArrayList<>();
        this.stream = false;
    }
    
    public OllamaChatRequest(String model, List<OllamaChatMessage> messages, boolean stream) {
        this.model = model;
        this.messages = messages != null ? messages : new ArrayList<>();
        this.stream = stream;
    }
    
    public String getModel() {
        return model;
    }
    
    public void setModel(String model) {
        this.model = model;
    }
    
    public List<OllamaChatMessage> getMessages() {
        return messages;
    }
    
    public void setMessages(List<OllamaChatMessage> messages) {
        this.messages = messages != null ? messages : new ArrayList<>();
    }
    
    public void addMessage(String role, String content) {
        this.messages.add(new OllamaChatMessage(role, content));
    }
    
    public void addUserMessage(String content) {
        addMessage("user", content);
    }
    
    public void addAssistantMessage(String content) {
        addMessage("assistant", content);
    }
    
    public void addSystemMessage(String content) {
        addMessage("system", content);
    }
    
    public boolean isStream() {
        return stream;
    }
    
    public void setStream(boolean stream) {
        this.stream = stream;
    }
    
    @Override
    public String toString() {
        return "OllamaChatRequest{" +
                "model='" + model + '\'' +
                ", messages=" + messages +
                ", stream=" + stream +
                '}';
    }
}
